package com.dream.system.service.impl;

import org.springframework.stereotype.Component;

import com.dream.common.Common;
import com.dream.common.SuperDao;
import com.dream.model.Sys_Class;
import com.dream.model.TellValidate;
import com.dream.system.service.TellValidateService;

@Component("tellValidateServiceImpl")
public class TellValidateServiceImpl extends SuperDao<Object> implements TellValidateService {

	@Override
	public void addTellCode(String tellId, String code, long l) {
		// TODO Auto-generated method stub
		TellValidate tv = new TellValidate();
		tv.setTell(tellId);
		tv.setCode(Integer.parseInt(code));
		tv.setDateTime(l);
		tv.setCreateTime(Common.getTime1());
		tv.setShowTime(Common.getTime());

		String hql = "from TellValidate t where t.tell = ? ";

		Object[] obj = new Object[] { tellId };

		Object tvtemp = (Object) this.getListOne(hql, obj, "");
		if (tvtemp == null) {
			this.addT(tv);
		} else {
			TellValidate tv1 = (TellValidate) tvtemp;
			tv1.setCode(Integer.parseInt(code));
			tv1.setDateTime(l);
			tv1.setCreateTime(Common.getTime1());
			tv1.setShowTime(Common.getTime());
			this.updateT(tv1);
		}
	}

	/**
	 * 
	 * 查询班级
	 */
	@Override
	public Sys_Class getClassCode(String code) {
		// TODO Auto-generated method stub
		String hql = "from Sys_Class t where t.cpassword = ? ";
		Object[] obj = new Object[] { code };
		Object tvtemp = (Object) this.getListOne(hql, obj, "");
		return (Sys_Class) tvtemp;
	}

}
